|
|
|
|
|
|
|
Figure 10.2
A binary tree with depth five. |
|
|
|
|
|
|
|
|
suitably rotated. The routine takes as a parameter its level in the tree so that it knows when to stop drawing. |
|
|
|
|
|
|
|
|
The DrawBranch routine shown in the following code does this. First it calculates where its main branch should end, and it draws the branch. Its length parameter gives the branch's length. Parameter theta gives the branch's direction in radians. |
|
|
|
|
|
|
|
|
If the current depth is greater than one, the routine recursively calls itself to draw two new branches. Those branches are shorter than the main branch by a factor of LENGTH_SCALE and are drawn in the directions theta + DTHETA and theta DTHETA. |
|
|
|
 |
|
|
|
|
Private Const PI = 3.14159
Private Const LENGTH_SCALE = 0.75
Private Const DTHETA = PI / 5
' Recursively draw a binary tree branch. Private Sub DrawBranch(ByVal depth As Integer, _
ByVal X As Single, ByVal Y As Single, _ |
|
|
|
|
|